proc

The proc command is a C-calculator command used to define procedures. Procedures differs from functions in the fact that they do not return any value. The procedure arguments are passed and referred to the same way they are in functions. Keyword proc is a C-calculator mode command. The show table command can be used to list all the installed objects at a given time.

proc procedurename(proto-list) cmode-line-statement or proc procedurename(proto-list) {
cmode-statements
}

     # The following example will print the Fibonacci numbers lower than 1000
     cmode
         proc fib(x) { 
             a = 0 
             b = 1 
             while (b < x) { 
                 print b
                 c = b 
                 b += a 
                 a = c 
             } 
             print "\n"
         } 
         # The following 'for' loop is equivalent to the preceding fib()
         proc fib2(x) {
             auto a,b,c        # This proc creates no global variable

             for(a=0,b=1;b<x;c=b,b+=a,a=c) {
                 print b
             }
             print "\n"
         }
         fib(1000)  # A procedure as called from C-calculator mode.
    fmode
    let fib2(1000)  # A procedure as called from fitting mode.
    # A short example involving a vector
    set data 10
    let proc init(X, x) X=x
    let b=3
    let init(Y, 2/4 + b) # Shows that scalar can also be expressions.

return, cmode, C, func, auto, math, show table, install